package com.jiang.smartdangjian.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jiang.smartdangjian.R;
import com.jiang.smartdangjian.tool.MyAdapter;

import java.util.Arrays;
import java.util.List;

public class S2Activity extends BaseActivity {

    private RecyclerView rv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_s2);
        initView();
        setTitle("组织活动");
    }

    private void initView() {
        rv = (RecyclerView) findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(getThis()));
        List<Bean2> bean2s = Arrays.asList(
                new Bean2("“学党史、悟思想、办实事”美化社区志愿服务主题活动", "广东省珠海市金湾区藤山社区",
                        "2021-06-14 14:30至2021-06-14 17:00", R.drawable.hd1),
                new Bean2("“学党史、悟思想、办实事”美化社区志愿服务主题活动", "广东省珠海市金湾区藤山社区",
                        "2021-06-14 14:30至2021-06-14 17:00", R.drawable.hd2),
                new Bean2("“学党史、悟思想、办实事”美化社区志愿服务主题活动", "广东省珠海市金湾区藤山社区",
                        "2021-06-14 14:30至2021-06-14 17:00", R.drawable.hd3),
                new Bean2("“学党史、悟思想、办实事”美化社区志愿服务主题活动", "广东省珠海市金湾区藤山社区",
                        "2021-06-14 14:30至2021-06-14 17:00", R.drawable.hd4),
                new Bean2("“学党史、悟思想、办实事”美化社区志愿服务主题活动", "广东省珠海市金湾区藤山社区",
                        "2021-06-14 14:30至2021-06-14 17:00", R.drawable.hd5));
        rv.setAdapter(new MyAdapter<Bean2>(getThis(), R.layout.item_hd, bean2s) {
            private ImageView imageView4;
            private TextView textView4;
            private TextView textView5;
            private TextView textView6;
            private TextView textView27;

            @Override
            public void init(View root, int position) {
                imageView4 = (ImageView) root.findViewById(R.id.imageView4);
                textView4 = (TextView) root.findViewById(R.id.textView4);
                textView5 = (TextView) root.findViewById(R.id.textView5);
                textView6 = (TextView) root.findViewById(R.id.textView6);
                textView27 = (TextView) root.findViewById(R.id.textView27);

                Bean2 bean2 = list.get(position);
                textView4.setText(bean2.name);
                textView5.setText(bean2.address);
                textView6.setText(bean2.date);
                imageView4.setImageResource(bean2.img);
                root.setOnClickListener(v -> startActivity(new Intent(getThis(),S2DActivity.class)));
            }
        });
    }
    static class Bean2 {
        String name, address, date;
        int img;

        public Bean2(String name, String address, String date, int img) {
            this.name = name;
            this.address = address;
            this.date = date;
            this.img = img;
        }
    }
}